package com.start.shop.api.vo.coupon;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;

import com.start.shop.modules.repository.entity.Coupon;
import com.start.shop.modules.repository.entity.CouponConfig;

import lombok.Data;


@Data
public class CouponVo {
	
	/* 优惠券编号 */
	private int couponId;
	/* 优惠券类型 */
	private int sortId;
	private String couponName;
	private String couponCondition;
	private BigDecimal conditionAmt;
	private int conditionGoodsId;
	private int conditionGoodsType;
	private BigDecimal cutAmt;
	private String couponDesc;
	
	private boolean couponCanUse;
	
	/* 优惠券状态 */
	private String couponStatus;
	/* 开始时间 */
	private String startDate;
	/* 结束时间 */
	private String endDate;
	/* 创建时间 */
	private String createDate;
	

	public static CouponVo setData(Coupon coupon, CouponConfig couponConfig) {
		CouponVo couponVo = new CouponVo();
		couponVo.setCouponId(coupon.getCouponId());
		couponVo.setSortId(coupon.getSortId());
		couponVo.setCouponStatus(coupon.getCouponStatus());
		
		SimpleDateFormat form = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String startDate = form.format(coupon.getStartDate());
		couponVo.setStartDate(startDate);
		
		String endDate = form.format(coupon.getEndDate());
		couponVo.setEndDate(endDate);
		
		String createTime = form.format(coupon.getCreateDate());
		couponVo.setCreateDate(createTime);
		
		couponVo.setCouponName(couponConfig.getCouponName());
		couponVo.setCouponCondition(couponConfig.getCouponCondition());
		couponVo.setConditionGoodsId(couponConfig.getConditionGoods());
		couponVo.setConditionGoodsType(couponConfig.getConditionGoodsType());
		couponVo.setConditionAmt(couponConfig.getConditionAmt());
		couponVo.setCutAmt(couponConfig.getCutAmt());
		couponVo.setCouponDesc(couponConfig.getCouponDesc());
		
		//couponVo.setCouponCanUse(couponCanUse);
		return couponVo;
	}


}
